package Type;

public class Test3 {
    public static void main(String[] args) {

//        int num = 10;
//        String str1 = String.valueOf(num);
//        String str3 = num + " ";
//        System.out.println(str1);
//        System.out.println(str3);
//
//        boolean b = false;
//        String str2 = String.valueOf(b);
//        System.out.println(b);
//        String str4 = b + " ";
//        System.out.println(str4);

        Person p1 = new Person("张三", 20);
        String str = String.valueOf(p1);
        System.out.println(str);//需重写toString()方法

    }
}

class Person {
    String name;
    int age;

    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return "Type.Person{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}